###########################################################################
#                            TextMate Snippets                            #
###########################################################################
snippet hwck "File Copyright Declaration"
/* 
 *  Hisilicon K3 SOC camera driver source file 
 * 
 *  CopyRight (C) Huawei Technology Co., Ltd. 
 * 
 * Author:	  h00145353 
 * Email:	  alan.hefeng@huawei.com
 * Date:	  `!v strftime("%Y-%m-%d")`
 *
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. * 
 *
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */


endsnippet

snippet hwcu "File Copyright Declaration"
/* 
 * Copyright (c) Huawei Technology Co., Ltd. All Rights Reserved.
 * Huawei Technology Proprietary and Confidential. 
 * 
 * Author:	  h00145353 
 * Email:	  alan.hefeng@huawei.com
 * Date:	  `!v strftime("%Y-%m-%d")`
 */


endsnippet

snippet def "#define ..."
#define ${1}
endsnippet

snippet ifndef "#ifndef ... #define ... #endif"
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
#define ${1:SYMBOL} ${2:value}
#endif
endsnippet

snippet #if "#if #endif" !b
#if ${1:0}
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
#endif
endsnippet

snippet inc "#include local header (inc)"
#include "${1:`!p snip.rv = snip.basename + '.h'`}"
endsnippet

snippet Inc "#include <> (Inc)"
#include <${1:.h}>
endsnippet

snippet mark "#pragma mark (mark)"
#if 0
${1:#pragma mark -
}#pragma mark $2
#endif

$0
endsnippet

snippet main "main() (main)"
int main(int argc, char *argv[])
{
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
	return 0;
}
endsnippet

snippet for "for loop (for)"
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet fori "for int loop (fori)"
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet enum "Enumeration"
enum ${1:name} { $0 };
endsnippet

snippet once "Include header once only guard"
#ifndef ${1:`!p
if not snip.c:
	import random, string
	name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper()
	rand = ''.join(random.sample(string.ascii_letters+string.digits, 8))
	snip.rv = ('%s_%s' % (name,rand)).upper()
else:
    snip.rv = snip.c`}
#define $1

${0}

#endif /* end of include guard: $1 */

endsnippet

snippet td "Typedef"
typedef ${1:int} ${2:MyCustomType};
endsnippet

snippet wh "while loop"
while(${1:/* condition */}) {
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet do "do...while loop (do)"
do {
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
} while(${1:/* condition */});
endsnippet

snippet fprintf "fprintf ..."
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet

snippet if "if .. (if)"
if (${1:/* condition */})
{
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet el "else .. (else)"
else {
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet ife "if .. else (ife)"
if (${1:/* condition */})
{
	${2:/* code */}
}
else
{
	${3:/* else */}
}
endsnippet

snippet printf "printf .. (printf)"
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet

snippet st "struct"
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`}
{
	${0:/* data */}
};
endsnippet

snippet fun "function" b
${1:void} ${2:function_name}(${3})
{
	${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet fund "function declaration" b
${1:void} ${2:function_name}(${3});
endsnippet

# vim:ft=snippets:
